import javax.swing.text.html.ListView;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 23735
 * Date: 2023-06-27
 * Time: 20:22
 */
public class Solution {
    public int maxVowels(String s, int k) {
        int len = s.length();
        int left = 0;
        int right = 0;
        int count = 0;
        // 固定长度的滑动窗口
        while (right < len && k > 0) {
            char c = s.charAt(right);
            if (isVowel(c)) {
                // 是元音字母
                count++;
            }
            right++;
            k--;
        }
        int max = count;
        for (; right < len; right++, left++) {
            if (isVowel(s.charAt(right))) {
                count++;
            }
            if (isVowel(s.charAt(left))) {
                count--;
            }
            max = Math.max(count, max);
        }
        return max;
    }

    private boolean isVowel(char c) {
        return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
    }
}
